package com.servicesystem.servicesystem.service.ali.ali;

import com.servicesystem.servicesystem.service.ali.SelectGoodsService;
import com.servicesystem.servicesystem.untis.HttpRequestAll;
import com.servicesystem.servicesystem.untis.R;
import com.servicesystem.servicesystem.untis.ali.AliData;
import com.servicesystem.servicesystem.untis.ali.AliSign;
import com.servicesystem.servicesystem.untis.ali.RequestUrl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class SelectGoodsServiceImp implements SelectGoodsService {

    private final HttpRequestAll httpRequestAll = new HttpRequestAll();

    @Override
    public R getSelectGoodsGroup(Long current) throws Exception {
        Map<String, String> params = new HashMap<>();
        params.put("access_token", AliData.ACCESS_TOKEN);
        params.put("pageNo", current.toString());
        params.put("pageSize", 16 + "");
        String signature = AliSign.getSignature("param2/1/com.alibaba.p4p/alibaba.cps.op.listCybUserGroup/5307039", params);
        Map<String, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("access_token", AliData.ACCESS_TOKEN);
        objectObjectHashMap.put("pageNo", current);
        objectObjectHashMap.put("pageSize", 16);
        objectObjectHashMap.put("_aop_signature", signature);
        return httpRequestAll.doPostWithParams(RequestUrl.SELECT_GOODS_GROUP, objectObjectHashMap);
    }

    @Override
    public R getSelectGoods(Long current, String groupId) throws Exception {
        Map<String, String> params = new HashMap<>();
        params.put("access_token", AliData.ACCESS_TOKEN);
        params.put("pageNo", current.toString());
        params.put("groupId", groupId);
        params.put("pageSize", 16 + "");
        String signature = AliSign.getSignature("param2/1/com.alibaba.p4p/alibaba.cps.op.listCybUserGroupFeed/5307039", params);
        Map<String, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("access_token", AliData.ACCESS_TOKEN);
        objectObjectHashMap.put("pageNo", current);
        objectObjectHashMap.put("groupId", groupId);
        objectObjectHashMap.put("pageSize", 16);
        objectObjectHashMap.put("_aop_signature", signature);
        return httpRequestAll.doPostWithParams(RequestUrl.SELECT_GOODS_LIST, objectObjectHashMap);
    }
}
